<!-- 
此组件初始化时不会自动加载数据，请在mounted中 this.$refs.[].initData()
如果放在dialog里面的吗，请在dialog的open事件中用this.$nextTick进行加载
 -->
<template>
  <div>
    <list id-key="id" ref="list" unit="客户" :disabled="disabled" :show-query="showQuery" show-checkbox
      :query-params="queryParams" :expand-query="expandQuery" :show-summary="showSummary" :page="page"
      :get-page-list-func="api.getPageList" :delete-func="api.deleteById">
      <template #toolbar-left>
        <slot name="toolbar-left"></slot>
      </template>
      <template #query>
        <!-- <el-form-item label="ID">
          <el-input v-model.trim="queryParams.id" clearable></el-input>
        </el-form-item> -->
        <div>
          <el-form-item label="客户代码">
            <el-input v-model.trim="queryParams.code" placeholder="客户代码" clearable></el-input>
          </el-form-item>
          <!-- <el-form-item label="原始名称">
            <el-input
              v-model.trim="queryParams.name"
              placeholder="客户原始名称"
              clearable
            ></el-input>
          </el-form-item> -->
          <el-form-item label="英文名称">
            <el-input v-model.trim="queryParams.enName" placeholder="客户英文名称" clearable></el-input>
          </el-form-item>
          <el-form-item label="中文名称">
            <el-input v-model.trim="queryParams.zhName" placeholder="客户中文名称" clearable></el-input>
          </el-form-item>
        </div>
        <div>
          <el-form-item label="名称唯一">
            <el-input v-model.trim="queryParams.nameUniqueValue" placeholder="英文名称唯一值" clearable></el-input>
          </el-form-item>
          <el-form-item label="中文名称唯一" label-width="85px">
            <el-input v-model.trim="queryParams.nameLocalizationUniqueValue" placeholder="中文名称唯一值" clearable></el-input>
          </el-form-item>
          <el-form-item label="多语言字段" label-width="85px">
            <el-input v-model.trim="queryParams.localizationText" placeholder="多语言字段" clearable></el-input>
          </el-form-item>
        </div>
        <div>
          <el-form-item label="客户ID">
            <el-input v-model="queryParams.idString" placeholder="客户ID，以,分隔" clearable
              style="width:800px;max-width:none"></el-input>
          </el-form-item>
        </div>
      </template>
      <template #column>
        <el-table-column prop="code" width="100" label="客户代码" show-overflow-tooltip />
        <!-- <el-table-column
          prop="status"
          width="90"
          label="发票状态"
          align="center"
        >
          <template #default="{ row }">
            <el-tooltip :content="row.nuoNuoMessage" :disabled="row.status!=6">
              <el-tag :type="getStatusType(row.status)">{{
                row.statusText
              }}</el-tag></el-tooltip
            >
          </template>
        </el-table-column> -->
        <el-table-column prop="enName" min-width="180" label="英文名称" show-overflow-tooltip>
          <template #default="{ row }">
            <el-tag v-if="row.isDeleted" type="danger" style="margin-right:5px">已作废</el-tag>
            <el-tag v-if="row.id != row.mergerId" type="warning" style="margin-right:5px">已合并</el-tag>
            <span class="c-link" @click="openDetail(row.id)">{{ row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="zhName" width="180" label="中文名称" show-overflow-tooltip />
        <el-table-column prop="nameUniqueValue" width="180" label="名称唯一值" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="nameLocalizationUniqueValue" width="180" label="中文名称唯一值" show-overflow-tooltip />
        <!-- <el-table-column
          prop="examineState"
          width="100"
          label="审批状态"
          show-overflow-tooltip
        >
          <template #default="{ row }">
            {{ row.nuoNuoStatusText }}
          </template>
        </el-table-column> -->
        <el-table-column prop="address" width="200" label="原始地址" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="enAddress" width="180" label="英文地址" show-overflow-tooltip />
        <el-table-column prop="zhAddress" width="180" label="中文地址" show-overflow-tooltip />
        <el-table-column prop="creationTime" width="120" label="创建时间" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.creationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="lastModificationTime" width="120" label="更新时间" sortable="custom">
          <template v-slot="{ row }">
            <span>{{ row.lastModificationTime | toShortDatetimeString }}</span>
          </template>
        </el-table-column>
        <!-- slot[column] -->
        <slot name="column"></slot>
        <!--/ slot[column]-->
      </template>
    </list>
    <detail-dialog ref="detailDialog" :in-dialog="inDialog" />
  </div>
</template>
<script>
import listMixin from "@/mixins/list";
import list from "@/components/common/list";
import detailDialog from "@/components/crm/customer/detailDialog";
import api from "@/api/crm/customer";
export default {
  mixins: [listMixin],
  components: {
    list,
    detailDialog,
  },
  props: {},
  data() {
    return {
      //查询条件字段
      queryParams: {
        name: "",
        enName: "",
        zhName: "",
        address: "",
        statuses: [],
        nameLocalizationUniqueValue: ""
      },
      api,
    };
  },
  methods: {
    getStatusType(status) {
      var text = "";
      switch (status) {
        case 0:
          text = "info";
          break;
        case 1:
          text = "";
          break;
        case 2:
          //作废
          text = "info";
          break;
        case 3:
          //冲红
          text = "warning";
          break;
        case 6:
          text = "danger";
          break;
      }
      return text;
    },
    openDetail(id) {
      this.$refs.detailDialog.openDetail(id);
    },
  },
};
</script>